//
//  ColorMaths.h
//  iOSStudy
//
//  Created by Evan Xie on 11/26/15.
//  Copyright © 2015 Family Wings. All rights reserved.
//


/**
 Reference: 
 http://dystopiancode.blogspot.hk/2012/06/hsv-rgb-conversion-algorithms-in-c.html
 https://www.cs.rit.edu/~ncs/color/t_convert.html
 
 HSV, see RGB_color_circle.png
 - Hue: [0, 359], 360 degree totally.
    0    degree: Red
    60  degrees: Yellow
    120 degrees: Green
    180 degrees: Cyan
    240 degrees: Blue
    300 degrees: Magenta
 */

#ifndef ColorMaths_h
#define ColorMaths_h

typedef struct {
    float red;    /* 0 ~ 1.0 */
    float green;  /* 0 ~ 1.0 */
    float blue;   /* 0 ~ 1.0 */
}RGBColor;

typedef struct {
    float hue;          /* 0 ~ 1.0 */
    float satuation;    /* 0 ~ 1.0 */
    float value;        /* 0 ~ 1.0 Brightness */
}HSVColor;

/**
 Convert RGB to HSV color
 
 @return If parameters are invalid, return false
 */
bool RGBToHSV(RGBColor *inRGB, HSVColor *outHSV);

/**
 Convert HSV to RGB color
 
 @return If parameters are invalid, return false
 */
bool HSVToRGB(HSVColor *inHSV, RGBColor *outRGB);

#endif /* ColorMaths_h */
